package test;

import com.bean.Employee;
import com.dao.EmployeeDao;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.sql.Date;


public class test {
    public static void main(String[] args) throws ParseException {
        java.util.Date d = new java.util.Date();
        Date date = new java.sql.Date(d.getTime());
        SimpleDateFormat formattery = new SimpleDateFormat("yyyy");
        SimpleDateFormat formatter = new SimpleDateFormat("MM");
        java.util.Date dd = formattery.parse("2019");
        dd=formatter.parse("09");
        String year=formattery.format(date);
        String month = formatter.format(date);

        System.out.println(dd);
        System.out.println(year+" "+month);
        /*EmployeeDao employeeDao = new EmployeeDao();
        Employee employee=new Employee("124","zhangsan","1234","01",true,false);
        employeeDao.addEmployee(employee);*/
        //删除
        //employeeDao.deleteEmployee("124");
        //改
        //employeeDao.updateEmployee(employee);
        //employee=employeeDao.getEmployee("124");
        EmployeeDao employeeDao = new EmployeeDao();
        Employee employee=null;
        List<Employee> employees = new ArrayList<>();
        employees = employeeDao.getEmployeeListByDept("02");
        for (int i = 0; i < employees.size(); i++) {
            employee = employees.get(i);
            System.out.println(employee.getName());
        }
        // 放5个Hero进入容器
        // 第三种，增强型for循环
        System.out.println("--------增强型for循环-------");
        for (Employee h : employees) {
            System.out.println(h.getName()+" "+ h.getDeptid());
        }
    }
}

